define(['app'], function(app) {
	'use strict';

	// 实例化方法
	var factory = function(Http) {

		//新品赠送活动自动抽奖
		function get_data_draw(result) {
			if(HTTP_ISLOGIC) {
				result = '{"success": true,"msg": "","result": {"act_id": "001","member": [{"member_id": "001","name": "张三","region": "江苏","is_prize": true,"order_status": "未发货"},{"member_id": "002","name": "张三","region": "江苏","is_prize": true,"order_status": "未发货"}],"choose_count": 1000},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else
				return result;
		}

		//显示新品赠选取送申请用户
		function get_data_show(result) {
            if(HTTP_ISLOGIC) {
                result = '{"success": true,"msg": "","result": {"act_id": "001","apply_count": 1000,"right_count": 1000,"prize_count": 1000,"member": [{"member_id": "001","name": "张三","region": "江苏","is_prize": true,"order_id": "001","order_status": "未发货"},{"member_id": "002","name": "张三","region": "江苏","is_prize": true,"order_id": "001","order_status": "未发货"}],"choose_count": 1000},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
                return JSON.parse(result);
            } else
                return result;
        }

		// 返回信息
		return {
			//新品赠送活动自动抽奖
			draw: function(act_id, draw_type, callback) {
				Http.post({
					method: 'marketing.giving.draw',
					act_id: act_id,
					draw_type: draw_type
				}, function(result) {
					if(callback)
						callback(get_data_draw(result).result);
				}, function(e) {

				}, function() {

				});
			},
			//新品申请用户
			show_getlist:function(act_id,callback){
			    Http.post({
                    method: 'marketing.giving.result',
                    act_id: act_id,
                }, function(result) {
                    if(callback)
                        callback(get_data_show(result).result);
                }, function(e) {

                }, function() {

                });
			},

		};
	}

	factory.$inject = [ 'Http' ];
	return app.registerService("Save", factory);
});